package com.simtop.controller;

import com.simtop.common.ServerResponse;
import com.simtop.pojo.Echarts3;
import com.simtop.pojo.User;
import com.simtop.service.EchartsService;
import com.simtop.service.UserService;
import com.simtop.util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author lvyongwei
 */
@RestController
@RequestMapping("/chart")
@CrossOrigin
public class ChartController {

    @Autowired
    private UserService userService;

    @Autowired
    private EchartsService echartsService;

    /**
     * 获取首页图表内容
     * @return
     */
    @GetMapping("/topPage")
    public ServerResponse getTopPage(){
        try{
            return userService.getTopPageCount();
        }catch (Exception e){
            return ServerResponse.createByErrorMsg("查询图表内容失败");
        }
    }
    /**
     * 用户实验成绩分布图
     * @param request
     * @return
     */
    @RequestMapping(value = "/score",method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse<Echarts3> selectScoreUser(HttpServletRequest request, HttpServletResponse response){
        return echartsService.selectScoreUser();
    }
}
